package com.ego.common.vo.order;

import com.ego.common.constant.OrderConstant;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.Objects;

/**
 * @program: ego
 * @description: 支付宝异步返回结果，详情见官网：https://opendocs.alipay.com/open/270/105902
 * @author: KamTang
 * @create: 2022-12-29 10:28
 **/
@Setter
@Getter
public class PayAsyncVo {

    private Date gmt_create;
    private String charset;
    private String gmt_payment;
    private Date notify_time;
    private String subject;
    private String sign;
    /**
     * 支付者的id
     */
    private String buyer_id;
    /**
     * 订单的信息
     */
    private String body;

    private String invoice_amount;
    private String version;

    private String notify_id;
    private String fund_bill_list;
    /**
     * 通知类型； trade_status_sync
     */
    private String notify_type;
    /**
     * 订单号
     */
    private String out_trade_no;
    /**
     * 支付总额
     */
    private String total_amount;
    /**
     * 交易状态
     */
    private String trade_status;
    /**
     * 流水号
     */
    private String trade_no;
    private String auth_app_id;
    /**
     * 商家收到的款
     */
    private String receipt_amount;
    private String point_amount;
    /**
     * 应用id
     */
    private String app_id;
    /**
     * 最终支付的金额
     */
    private String buyer_pay_amount;
    /**
     * 签名类型
     */
    private String sign_type;
    /**
     * 商家的id
     */
    private String seller_id;

    /**
     * 是否支付成功
     */
    public boolean paySuccess() {
        return Objects.equals(this.trade_status, OrderConstant.TransactionStatusEnum.TRADE_SUCCESS.name()) ||
                Objects.equals(this.trade_status, OrderConstant.TransactionStatusEnum.TRADE_FINISHED.name());
    }
}
